<template>
  <div style="padding-bottom: 60px">
    <div class="el-card" style="margin:20px 5%; padding: 5px" v-for="item in orders">
      <span><van-tag v-if="item.isPay===true" type="success">已支付</van-tag><van-tag v-if="item.isPay===false" type="danger">未支付</van-tag>订单编号：{{item.id}}</span>
      <van-card v-for="shop in item.orderChildrens"
                :num="shop.stock"
                :price="shop.price"
                :title="shop.name"
                :thumb="shop.img"
      />
      <span style="float: right;margin-right: 10px">总价：￥{{item.price}}</span><van-button v-if="item.isPay===false" size="mini" type="info" @click="pay(item.id,item.price)">去支付</van-button>
    </div>
  </div>
</template>

<script>
import {doGetAllOrders, doGetOrdersbyid} from "@/api/order";

export default {
  name: "order",
  data(){
    return{
      orders:[]
    }
  },
  methods:{
    getAllOrder(){
      doGetOrdersbyid(window.localStorage.getItem("sid")).then(res=>{
        if (res.code===200){
          this.orders=res.data;
        }
      })
    },
    pay(id,total){
      this.$store.state.orderId=id;
      this.$store.state.total=total;
      this.$router.push('pay')
    }
  },
  mounted() {
    this.getAllOrder();
  }
}
</script>

<style scoped>

</style>
